#include "thingsbehind.h"
#include "ui_thingsbehind.h"
#include "menu.h"
#include <QPainter>
#include <QFont>
#include <QPixmap>
#include <QTimer>

int i0=1;

thingsbehind::thingsbehind(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::thingsbehind)
{
    ui->setupUi(this);
}

void thingsbehind::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setPen(Qt::black);//设置画笔颜色
    painter.setBrush(Qt::black);//设置填充颜色
    painter.drawRect(0,0,480,480);
    int x1=ui->qhframe->pos().x();
    int y1=ui->qhframe->pos().y();
    qh[0].load(":/resourse/1.png") ;
    qh[1].load(":/resourse/p6.png") ;
    qh[2].load(":/resourse/p7.JPG") ;
    qh[3].load(":/resourse/p8.JPG") ;
    qh[4].load(":/resourse/p9.png") ;
    qh[5].load(":/resourse/p10.JPG") ;
    qh[6].load(":/resourse/p11.png") ;
    qh[7].load(":/resourse/p12.JPG") ;
    QFont font1("Courier New",15);
    painter.setFont(font1);
    painter.setPen(Qt::white);
    painter.setBrush(Qt::white);
    if (i0<=13)
        painter.drawText(20,370,dialog[i0]);
    if (i0==14)
    {
        painter.setPen(Qt::red);
        painter.setBrush(Qt::red);
        painter.drawText(20,370,dialog[i0]);
    }
    if (i0==4||i0==5||i0==6||i0==7)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[0]);
    }
    if (i0==8)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[6]);
    }
    if (i0==9)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[1]);
    }    
    if (i0==10)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[4]);
    }
    if (i0==11)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[5]);
    }
    if (i0==12)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[2]);
    }
    if (i0==13)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[3]);
    }
    if (i0==14)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[7]);
    }
    if (i0==15)
    {
        i0=1;
        this->close();
//      Menu *M =new Menu();
//      M->show();
    }

}

void thingsbehind::on_nextpushButton_clicked()
{
    i0++;
    update();
}

thingsbehind::~thingsbehind()
{
    delete ui;
}
